/*
 * Copyright (c) 2016- 2020 qolome.com Inc. All Rights Reserved.
 * ProjectName: qolome-knowledge
 * FileName: Hanlder.java
 * Author: jiangfeng@qolome.com
 * Date: 2020/3/16 下午3:42
 * LastModified: 2020/03/16 15:42:16
 */

package com.qolome.knowledge.design.pattern.responsibilitychain.demo.authentication;


import java.util.Objects;

/**
 * @author Qolome
 * @version V1.0
 * @Description 处理
 * @date 2020年 03月16日 15:42:28
 */
public abstract class BaseHandler<T> {

    protected BaseHandler next;
    public void next(BaseHandler next){
        this.next = next;
    }
    public  abstract void doHanlder(AuthenticationInfo authenticationInfo);


    public  static  class Builder<T>{

        private BaseHandler head;
        private BaseHandler tail;

        public Builder<T> addHander(BaseHandler hanlder){

            if (Objects.isNull(this.head)){
                this.head = this.tail = hanlder;
                return this;
            }
            this.tail.next(hanlder);
            this.tail = hanlder;
            return this;
        }



        public BaseHandler<T> build(){
            return this.head;
        }




    }
}
